<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="x-ua-compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>支付页</title>
    <link rel="shortcut icon" href="">
    <link rel="stylesheet" href="__PUBLICINDEX__/css/base.css" />
    <link rel="stylesheet" href="__PUBLICINDEX__/css/common.css" />
    <link rel="stylesheet" href="__PUBLICINDEX__/css/pay.css" />
    <script type="text/javascript" src="__PUBLICINDEX__/js/html5shiv.js"></script>
    <script type="text/javascript" src="__PUBLICINDEX__/js/respond.min.js"></script>
    <script type="text/javascript" src="__PUBLICINDEX__/js/jquery-1.11.3.min.js"></script>
</head>
<body>
    {include file="common/head"}
<!--支付第一步-->
<div class="firstly">
    <div class="bindmobile-wrap">
        采用<span style="color:red">微信支付</span>，购买成功后，团购券将发到您的注册邮箱：<span class="mobile">{$user['email']}</span><a class="link"></a>
    </div>
    <table class="table table-goods" cellpadding="0" cellspacing="0">
        <tbody>
            <tr>
                <th class="first">商品</th>
                <th width="120">单价</th>
                <th width="190">数量</th>
                <!-- <th width="140">优惠</th> -->
                <th width="140" class="last">小计</th>
            </tr>
            <tr class="j-row">
                <td class="vtop">
                    <div class="title-area" title="{$deal['name']}">
                        <div class="img-wrap">
                            <a href="" target="_blank"><img src="{$deal['image']}" width="130" height="79"></a>
                        </div>
                        <div class="title-wrap">
                            <div class="title">
                                <a href="" class="link">{$deal['name']}</a>
                            </div>
                            <div class="attrs"></div>
                        </div>
                    </div>
                </td>
                <td>￥<span class="font14">{$deal['current_price']}</span></td>
                <td class="j-cell">
                    <div class="buycount-ctrl">
                        <a class="j-ctrl ctrl minus disabled"><span class="horizontal"></span></a>
                        <input type="text" value="{$count}" maxlength="10">
                        <a class="ctrl j-ctrl plus"><span class="horizontal"></span><span class="vertical"></span></a>
                    </div>
                    <span class="err-wrap j-err-wrap"></span>
                </td>
                <!-- <td class="j-cellActivity">-￥<span>1.40</span><br></td> -->
                <td class="price font14">¥<span class="j-sumPrice">{$deal['current_price']*$count}</span></td>
            </tr>
        </tbody>
    </table>
    <div class="final-price-area">应付总额：<span class="sum">￥<span class="price">{$deal['current_price']*$count}</span></span></div>
    <div class="page-button-wrap">
        <a class="btn btn-primary o2o_pay">确认</a>
    </div>
    <div style="width: 100%;min-width: 1200px;height: 5px;background: #dbdbdb;margin: 50px 0 20px;"></div>
</div>
<script>
    //校验正整数
    function isNaN(number){
        var reg = /^[1-9]\d*$/;
        return reg.test(number);
    }

    function inputChange(num){
        if(!isNaN(num)){
            $(".buycount-ctrl input").val("1");
        }
        else{
            $(".buycount-ctrl input").val(num);
            $(".j-sumPrice").text($("td .font14").text() * num - $(".j-cellActivity span").text());
            $(".sum .price").text($("td .font14").text() * num - $(".j-cellActivity span").text());
            if(num == 1){
                $(".buycount-ctrl a").eq(0).addClass("disabled");
            }
            else{
                $(".buycount-ctrl a").eq(0).removeClass("disabled");
            }
        }
    }

    $(".buycount-ctrl input").keyup(function(){
        var num = $(".buycount-ctrl input").val();
        inputChange(num);
    });
    $(".minus").click(function(){
        var num = $(".buycount-ctrl input").val();
        num--;
        inputChange(num);
    });
    $(".plus").click(function(){
        var num = $(".buycount-ctrl input").val();
        num++;
        inputChange(num);
    });
    $(".o2o_pay").click(function() {
      var count = $('.buycount-ctrl input').val(),
          price = $(".sum .price").text(),
          url = "{:url('order/index', ['id'=>$deal.id])}"+"&count="+count+"&total_price="+price;
      self.location=url;
      // window.open(url);
    });
</script>
</body>
</html>
